/**
 * @param {string} s
 * @return {number}
*/
var partitionString = function(s) {
  let temp = "", record = new Array(26).fill(false), count = 0;
  for(let i = 0; i < s.length; i++) {
    if(!temp) {
      temp += s[i];
      record[s[i].charCodeAt() - 'a'.charCodeAt()] = true;
    } else {
      if(record[s[i].charCodeAt() - 'a'.charCodeAt()]) {
        count++;
        record = new Array(26).fill(false);
        temp = s[i];
        record[s[i].charCodeAt() - 'a'.charCodeAt()] = true;
      } else {
        temp += s[i];
        record[s[i].charCodeAt() - 'a'.charCodeAt()] = true;
      }
    }

  }
  if(temp) count++;
  return count;
};
let s = "abacaba";
console.log(partitionString(s));
s = "ssssss";
console.log(partitionString(s));
s = "gizfdfri";
console.log(partitionString(s));
